# define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<math.h>
int main()
{
	for (int i = 0; i <= 100000; i++)
	{
		int t = i;
		int count = 0, sum = 0;
		if (t == 0)
		{
			count = 1;
		}
		else
		{
			while (t > 0)
			{
				t = t / 10;
				count++;
			}
		}
		t = i;
		while (t > 0)
		{
			sum += ((int)pow((t % 10), count));
			t = t / 10;
		}
		if (i == sum)
		{
			printf("%d\n",sum);
		}
	}
	return 0;
}